package com.roger.springcloudGreenwich.service.impl;

import org.elasticsearch.ElasticsearchException;
import org.elasticsearch.action.bulk.BulkItemResponse;
import org.elasticsearch.action.bulk.BulkRequestBuilder;
import org.elasticsearch.action.bulk.BulkResponse;
import org.elasticsearch.client.transport.TransportClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
import org.springframework.data.elasticsearch.core.query.IndexQuery;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

/**
 * Created by admin on 2020/3/16.
 */
@Service
public class IndexOper {
    @Autowired
    private ElasticsearchTemplate elasticsearchTemplate;
    @Autowired
    TransportClient client;

    public void addIndex(String indexName){
        elasticsearchTemplate.createIndex(indexName);
    }

    public void deleteIndex(String indexName){
        elasticsearchTemplate.deleteIndex(indexName);
    }

    public static void main(String[] args) {
        String s = "a+b+c";
        if(s.contains("+")){
            s = s.replace("+","%2b");
        }

        System.out.print(s);
    }

}
